<template>
	<view class="center">
		
		<view class="nav_bar" style="background-color: rgba(255, 255, 255, 1);" v-if="from_type != 1">
			<uni-nav-bar color="#333" left-icon="left" title="认证" :border='false' :fixed="true"
				background-color="transparent" @clickLeft="back"></uni-nav-bar>
		</view>

		<view class="nav_box" v-if="from_type != 1"></view>

		<view class="list flex_r_between" @click="toCertification">
			<view class="left flex_center">
				<image src="/static/expert/tags.png" mode="aspectFill"></image>
				<view class="text">
					<text>个人入驻</text>
					<view>个人实名认证</view>
				</view>
			</view>

			<view class="right flex_center" v-if="auth_info.auth_status && auth_info.auth_status == 2">
				<text>已认证</text>
			</view>
			<view class="right" v-else>
				<text style="color: #FD2A53;">去认证</text>
			</view>
		</view>

		<view class="list flex_r_between" @click="toQualification">
			<view class="left flex_center">
				<image src="/static/expert/tags.png" mode="aspectFill"></image>
				<view class="text">
					<text>资格认证</text>
					<view>法人实名认证及资格证书</view>
				</view>
			</view>

			<view class="right flex_center" v-if="auth_info.certificate">
				<text>已认证</text>
			</view>
			<view class="right" v-else>
				<text style="color: #FD2A53;">去认证</text>
			</view>
		</view>
		
		<view class="list flex_r_between" @click="toEnterprise">
			<view class="left flex_center">
				<image src="/static/expert/tags.png" mode="aspectFill"></image>
				<view class="text">
					<text>商家入驻</text>
					<view>法人实名认证及营业执照</view>
				</view>
			</view>
		
			<view class="right flex_center" v-if="companyAuth.company_status != 1 ">
				<text>{{
					companyAuth.company_status == 2 ? '已完成'
					: companyAuth.company_status == 3 ? '审核中'
					: companyAuth.company_status == 4 ? '未通过'
					: ''
				}}</text>
			</view>
			<view class="right" v-else>
				<text style="color: #FD2A53;">去认证</text>
			</view>
		</view>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				auth_info: {},

				qualification: {},
				
				from_type: 0,
				
				companyAuth: {
					company_status: 1,
					company_legal_name: '',
					company_legal_id_num: '',
					company_file_yyzz: '',
					create_circle_file: '',
				},
				
				need_close: 0,
				circle_id: 0,
				
				type: '',
				
				from_web: 0,
				
			}
		},

		methods: {
			toCertification() {
				if (uni.getSystemInfoSync().platform == 'android') {
					if(this.need_close == 1){
						this.$native.upgradeCircleSuccess(`${this.circle_id}`);
					}else {
						this.$native.backAction();
					}
					this.$native.toCertification();
				} else {
					this.$util.toUrl(`/pages/auth/certification?data=${JSON.stringify(this.auth_info)}&from_type=${this.from_type}&from_web=${this.from_web}`);
				}
			},

			toQualification() {
				
				if(this.auth_info.auth_status != 2){
					return this.$util.msg('请先完成实名认证');
				}
				
				this.$util.toUrl(`/pages/auth/qualification?data=${JSON.stringify(this.auth_info)}&from_type=${this.from_type}`);
			},
			
			toEnterprise(){
				
				if(this.auth_info.auth_status != 2){
					return this.$util.msg('请先完成实名认证');
				}
				
				this.$util.toUrl(`/pages/auth/enterprise?data=${JSON.stringify(this.companyAuth)}&type=${this.type}`);
			},

			getStatus() {
				this.$post('/user/getProviderInfo').then(res => {
					this.auth_info = res.data || {};
				});
			},
			
			getCompanyAuth(){
				this.$post('/circle.circle/getCompanyAuth').then(res=>{
					this.companyAuth = res.data;
				});
			},
			
			back(){
				if(this.from_web == 1){
					this.$util.back();
				}else {
					this.$native.backAction();
				}
			},

		},

		onLoad(option) {
			this.from_type = option.from_type || 0;
			this.need_close = option.need_close || 0;
			this.circle_id = option.circle_id || 0;
			this.type = option.type || '';
			this.from_web = option.from_web || 0;
			
			if (option.token) {
				uni.setStorageSync('token', option.token);
				uni.setStorageSync('cid', option.cid);
				uni.setStorageSync('terminal', option.terminal);
			}
			
			this.getStatus();
			this.getCompanyAuth();
		}

	}
</script>

<style lang="less" scoped>
	.center {
		padding: 40rpx 32rpx;
		min-height: 100vh;
		background: #FFFFFF;
	}

	.list {
		width: 686rpx;
		height: 176rpx;
		background: linear-gradient( 180deg, #FFF1F5 0%, #FFFFFF 100%);
		border-radius: 24rpx;
		border: 2rpx solid #FFEAEE;
		padding: 0 32rpx;
		margin-bottom: 20rpx;

		.left {
			image {
				width: 64rpx;
				height: 64rpx;
				margin-right: 16rpx;
			}
			
			.text {
				text {
					font-weight: 500;
					font-size: 32rpx;
					color: #192031;
					line-height: 44rpx;
				}
				
				view {
					font-size: 24rpx;
					color: #999999;
					line-height: 34rpx;
				}
			}
		}

		.right {
			text {
				font-size: 28rpx;
				color: #333333;
				margin-right: 16rpx;
			}
		}

	}
</style>